<template>
  <div class="movie">
     <swiper :options="swiperOption" ref="mySwiper">
      <swiper-slide v-for="(item, index) in detail.photos" :key="index">
         <img :src="item.bigPictureAddress" alt=""> 
      </swiper-slide>
      <div class="swiper-pagination"  slot="pagination"></div>
    </swiper> 
    <div class="file-intro">
      <div class="film">影片简介</div>
      <div class="film-content">
        <div class="film-item">
          <span>导&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;演:</span>
          <span>{{detail.director}}</span>
        </div>
        <div class="film-item">
          <span>主&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;演:</span>
           <span>{{detail.actors}}</span> 
        </div>
        <div class="film-item">
          <span>地区语言：</span>
          <span>{{detail.nation}}</span>
        </div>
        <div class="film-item">
          <span>类&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;型：</span>
          <span>{{detail.category}}</span>
        </div>
        <div class="film-item">
          <span>上映日期：</span>
          <span>{{detail.premiereAt | formatTime}}上映</span>
        </div>
        <div class="film-show">
          {{detail.synopsis}}
        </div>
      </div>
    </div>
   <div class="button">
      <button class="buy-ticket">立即购票</button>
   </div>
  </div>
</template>

<script>
import { getFilmDetail } from '@/api'
import { swiper, swiperSlide } from 'vue-awesome-swiper'
export default {
  data () {
    return {
      swiperOption: {
        notNextTick: true,
        autoplay: 3000,
        pagination: '.swiper-pagination',
        slidesPerView: 1,
        loop: true
      },
      detail: {}
    }
  },
  filters: {
    formatTime (time) {
      time = new Date(time)
      return `${time.getMonth() + 1}月${time.getDate()}日`
    }
  },
  created () {
    console.log(this.$route)
    getFilmDetail(this.$route.params.id).then(data => {
      console.log(data)
      this.detail = data.data.data.film
      this.detail.actors = this.detail.actors.reduce((a, b) => a.concat(b.name), []).join(' | ')
    })
  },
  components: {
    swiper, swiperSlide
  }
}
</script>

<style>
.swiper-slide img {
  width: 100%;
}
.film-content {
  color: #333;
}
.film {
  margin: 16px auto;
  border-left: 16px solid RGB(228, 200, 156);
  font-size: 16px;
  padding-left: 4px;
}
.film-item {
  height: 18px;
  overflow: hidden;
  margin-bottom: 10px;
  padding-left: 20px;
}
.film-show  {
  text-overflow: ellipsis;
  margin-bottom: 80px;
  padding-left: 20px;
  padding-right: 20px;
}
.button {
  text-align: center;
}
.buy-ticket {
  font-size: 14px;
  min-width: 156px;
  height: 36px;
  line-height: 36px;
  border: none;
  background-color: #fe8233;
  padding: 0;
  margin: 0;
  border-radius: 18px;
  color: #fff;
  -webkit-transition: 0.5s ease;  
}
</style>

